import React, { Component } from "react";
import { connect } from "react-redux";
import MainLayout from "../../../../component/mainLayout/mainLayout";
import { getAppPlatformsDatas } from "../../../../Redux/Action/nativeDatas/nativeDatas";
import { setUserType } from "../../../../Redux/Action/credit/AuthenticationA";
import "./index.scss";
import yhTools from "../../../../tools/yh";
import { InterfaceG } from "../../../../config/Config";
import { Toast } from "antd-mobile";

class inviteRecord extends Component {
	constructor(props) {
		super(props);
		this.state = {
			datas: []
		};
	}

	componentDidMount() {
		this.getDate();
	}

	getDate() {
		const objs = {
			url: InterfaceG.queryInviteActivityRewardList,
			params: {
				lnid: "601"
			}
		};
		Toast.loading("加载中...", 100);
		yhTools.request(objs).then(res => {
			if (res.code == "0") {
				this.setState({
					datas: res.data
				});
			}
		});
	}

	render() {
		const _pageParams = {
			header: {
				title: "奖励记录",
				goBackPath: "/inviteHome"
			},
			history: this.props.history,
			cacheLifecycles: this.props.cacheLifecycles
		};

		return (
			<MainLayout pageParams={_pageParams}>
				<div className="rewardRecord">
					<div className="list">
						{this.state.datas.map((item, index) => {
							return (
								<div className="item" key={index}>
									<div className="item_left">
										<div className="text1">{item.mobilePhone}</div>
										<div className="text2">{item.createDate}</div>
									</div>
									<div className="item_right">{item.couponValue}元优惠券</div>
								</div>
							);
						})}
					</div>
					<div className="no_more">-没有更多了-</div>
				</div>
			</MainLayout>
		);
	}
}

function mapStateToProps(state) {
	return state;
}

function mapDispatchToProps(dispatch) {
	return {
		_getAppPlatformsDatas: options => {
			// 同步数据
			dispatch(getAppPlatformsDatas(options));
		},
		_setUserType: options => {
			dispatch(setUserType(options));
		}
	};
}

export default connect(mapStateToProps, mapDispatchToProps)(inviteRecord);
